package Parser;

import java.io.File;
import java.util.ArrayList;

import Database.Paper;

public class BibtexDirectory
{
	private File file;
	public BibtexDirectory(String directoryName)
	{
		file = new File(directoryName);
		
		if (! file.isDirectory())
		{
			file = null;
			System.err.println(directoryName + " is not a directory.");
			return;
		}
	}
	
	public ArrayList<Paper> getPaperList()
	{
		ArrayList<Paper> list = new ArrayList<Paper>();
		
		if (file == null)
			return list;
		
		File files[] = file.listFiles();
		
		for (File f : files)
		{
			if (! f.getName().contains(".bib"))
				continue;
			
			BibtexFile bib = new BibtexFile(f);
			
			bib.parse();

			list.addAll(bib.getPaperList());
		}
		
		return list;
	}
}
